package com.itxh.mybatis.dao;

import com.itxh.core.factory.SqlSessionFactory;
import com.itxh.core.sqlsession.SqlSession;
import com.itxh.mybatis.po.User;

import java.util.List;


/**
 * 持久层代码
 * 
 * @author think
 *
 */
public class UserDaoImplWithMybatis implements UserDao {

	private SqlSessionFactory sqlSessionFactory;

	public UserDaoImplWithMybatis(SqlSessionFactory sqlSessionFactory) {
		this.sqlSessionFactory = sqlSessionFactory;
	}

	@Override
	public List<User> queryUserByName(String username) {
		SqlSession sqlSession = sqlSessionFactory.openSession();
		return sqlSession.selectList("test.queryUserByName",username);
	}

	@Override
	public User queryUserById(Integer id) {
		SqlSession sqlSession = sqlSessionFactory.openSession();
		return sqlSession.selectOne("test.queryUserById",id);
	}
}
